package com.pubinfo.passbook.excel;

import com.alibaba.excel.EasyExcel;
import com.pubinfo.passbook.common.mapper.TRabbitmqOrgConvertMapper;
import com.pubinfo.passbook.common.mapper.TRabbitmqPersonMapper;
import com.pubinfo.passbook.common.mapper.TSystemRoleMapper;
import com.pubinfo.passbook.common.model.bo.Excel;
import com.pubinfo.passbook.common.model.ruler.CompanyExcel;
import com.pubinfo.passbook.common.service.master.TSubsidiaryInfoService;
import com.pubinfo.passbook.common.service.master.TSubsidiaryPrivateKeyService;
import com.pubinfo.passbook.common.utils.CompanyExcelDataListener;
import com.pubinfo.passbook.common.utils.UploadInterfaceListener;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.File;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest
public class Excel2DB {
  @Autowired
  private TSubsidiaryPrivateKeyService keyService;
  @Autowired
  private TSubsidiaryInfoService infoService;
  @Autowired
  TRabbitmqPersonMapper tRabbitmqPersonMapper;
  @Autowired
  TSystemRoleMapper tSystemRoleMapper;
  @Autowired
  TRabbitmqOrgConvertMapper tRabbitmqOrgConvertMapper;

  @Test
  public void test1() {
    File file = new File("F:/Users/litiewang/Documents/WeChat Files/wxid_zciqnbt89xfj22/FileStorage/File/2021-08/0税务-电子发票接口密钥(汇总）8.20.xlsx");
    EasyExcel.read(file, Excel.class, new UploadInterfaceListener(keyService, infoService)).sheet().doRead();
  }

  @Test
  public void test2() {
    File file = new File("C:\\Users\\xuhong\\Downloads\\迁改赔补系统权限收集20220519(浙江传输局).xlsx");

    CompanyExcelDataListener companyExcelDataListener=new CompanyExcelDataListener(tRabbitmqPersonMapper,tSystemRoleMapper,tRabbitmqOrgConvertMapper);

    EasyExcel.read(file, CompanyExcel.class,companyExcelDataListener).headRowNumber(2).sheet().doRead();

    List<CompanyExcel> companyExcels=companyExcelDataListener.getList();



  }
  
}
